<?php
$id=empty($_POST['id'])?0:$_POST['id'];
$arr=getlist('category','pid='.$id);//顶级列表

if(!empty($_POST['name'])){
$date=$_POST;
$row=insert('category',$date);
if($row>-1){
	echo '<script>alert ("添加成功");location="index.php?admin=1&c=category&a=list";</script>';
	};

};
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH'])){
	echo json_encode($arr);exit;
}else{
$data=array('arr'=>$arr);
view($data);
}
?>